<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主</title>
<import type='css' file="css.main" />
<load href="__PUBLIC__/js/jquery-1.9.1.min.js" />
<import type='js' file="js.main" />
</head>

<body>  
<!-- 预览窗口开始 -->
<div class="previewbg">
	<h3></h3>
	<input></input>
	<iframe id="previewwidnow" src="" frameborder="0" scrolling="auto" style="width:375px;"></iframe>
</div>
<div class="previewbgeqcode">
	<iframe id="eqcodewidnow" src="" frameborder="0" scrolling="auto"></iframe>
</div>
<div class="jiumabg">
	<div class="jiuma">
    	<div class="jiumaclose">X</div>
		<div class="jiuma_from"><input type="hidden" name="ycid" /><input name='searkey' type="text" placeholder="输入某个码的标题" /><a id="searchsubmit">搜索</a></div>
		<div class="jiumalist">正在加载数据...</div>
	</div>
</div>
<!-- 预览窗口结束 -->
<!-- 用户列表开始 -->
<div class="user_tar">
	<div class="user_info">
		<b>X</b>
		<label class="u_float">用户列表：</label>
		<select class="u_float" name="userinfo">
			<volist name="userlist" id="user">
			<option value="{$user['id']}">{$user['username']}</option>
			</volist>
		</select>
		<a class="u_float user_ok">确定</a>
		<input type="hidden" name="ma_id"/>
		<input type="hidden" name="geturl" value="{$getURL}"/>
	</div>
</div>
<!-- 用户列表结束 -->
<div class="main-frame">
	<div class="position">华人码 > 华人码列表</div>
	<div class="table-list">
	 <table width="100%" border="1" cellspacing="0" cellpadding="0" class="indextable">
		    <tr class="th-bg">
			  <th width="30"></th>
		      <th width="6%">DmID</th>
		      <th width="30%">物语码标题</th>
		      <th width="8%">创建人</th>
              <th width="10%">菜单操作</th>
		      <th width="30%">操作</th>
			  <!--<th width="6%">扫码量</th>-->
			  <th width="5%">状态</th>
			  <th width="8%">创建时间</th>
	        </tr>

	        <volist name='list' id='data' empty="$empty">
		    <tr class="tr-line" title="企业名称：{$data.epname}&#10;模板：{:W('Menutype/gettpl',array($data['template']))}&#10;点击量：{$data.num}">
			  <td><input type="checkbox" <if condition="$Thinkphp.session.userinfo.type neq 1">disabled</if> value="{$data.id}" name="jur"/></td>
			  <td style="color: #aaa;">{$data.domainid}</td>
		      <td class="tbu">{$data.typename}<if condition="$Thinkphp.session.userinfo.type eq 1"><span v="{$data.id}">同步旧码</span></if></td>
		      <td style="color: #aaa;">{:W('Menutype/showuser',array('userid'=>$data['userid']))}</td>
              <td style="color: #e7e7e7;">
				  <notin name="data['template']" value="index8,index9">
					  <if condition="$Thinkphp.session.userinfo.type eq 1">
						  <a class="add_type" href="{:U('menuadd',array('rootid'=>$data['id']))}" title="添加"></a>
					  </if>
					  <a class="browe_type" href="{:U('/Admin/Index/menulist',array('id'=>$data['id']))}" title="查看"></a>
				  <else/>
					  ——
				  </notin>
			  </td>
		      <td>
		      	<a class='preview_t preview' name="{$data.typename}" path="/rootid/{$data['id']}.html" title="预览"></a>
				<a class='edit_t' href="{:U('Index/edit',array('id'=>$data['id']))}" title="编辑"></a>
		      	<if condition="$Thinkphp.session.userinfo.type eq 1">
		      		<a class="delete_t resdel" refurl="{:U('Type/delete',array('id'=>$data['id'],'table'=>'type','del'=>true))}" title="删除"></a>
		      	</if>
				<if condition="$data['state'] eq 1">
					<a class="code_t browseqrcode" domainid="{$data.domainid}" rootid="{$data.id}" title="二维码"></a>
					<a class="batchma" href="{:U('Batch/index',array('domainid'=>$data['domainid'],'rootid'=>$data['id']))}" title="促销管理"></a>
				</if>
				<if condition="$Thinkphp.session.userinfo.type eq 1">
				   <a href="{:U('Index/fuhua', array('rootid' => $data['id']))}" style="color: #f39c12; margin-left: 10px;">浮画</a>
				</if>
		      </td>
			  <!--<td>{$data['num']}</td>-->
			  <td>
				  <a <if condition="$Thinkphp.session.userinfo.type eq 1">onclick="changestate('{:U('Type/changestate',array('id'=>$data['id'],'state'=>$data['state'],'table'=>'type'))}')"</if>>
					  <switch name="data.state">
						  <case value="1"><span class="topen" title="正常"></span></case>
						  <case value="0"><span style="color: #ff5454;">审核中</span></case>
					  </switch>
				  </a>
			  </td>
			  <td style="font-size:12px;">{$data.crdate}</td>
	        </tr>
	        </volist>
      </table>
    </div>
	<div class="page"><if condition="$Thinkphp.session.userinfo.type eq 1"><a class="careof">转交</a></if>{$page}</div>
</div>
<script type="text/javascript">
	$(function(){
		//转交事件
		var jur = '';
		$("a.careof").click(function(){
			$('input[name="jur"]:checked').each(function(index, element) {
				jur += $(this).val()+",";
			});
			if(jur != ''){
				var s = jur.substring(0,jur.length-1);
				$(".user_tar").show();
				$("input[name='ma_id']").val(s);
			}
			jur = '';
			//alert($("input[name='ma_id']").val());
		})
		//关闭窗口
		$(".user_info b").click(function(){
			$("input[name='ma_id']").val(null);
			$(".user_tar").hide();
		})
		//执行转交
		$("a.user_ok").click(function(){
			var ma_id = $("input[name='ma_id']").val();
			var user_id = $(".user_info select").val();
			var user_name = $(".user_info select").find("option:selected").text();
			var geturl = $("input[name='geturl']").val();
			if(user_id !='' && ma_id != ''){
				var url = "/Admin/Index/jur";
				var data = {
					"ma_id":ma_id,
					"user_id":user_id,
					"user_name":user_name,
					random:Math.random()
				};
				$.ajax({
					url:url,
					data:data,
					type:"POST",
					dataType:"JSON",
					success:function (data){
						if(data.error == 0){
							alert("转交成功");
							location.href = geturl;
						}else{
							alert("转交失败");
						}
					},
				});
			}
		})

		$("a.resdel").each(function(index, element) {
			var t = $(this);
			t.click(function(){
				var r=confirm("想好！确定要删除吗？");
				if (r==true){
					var refurl = $(this).attr('refurl');
					location.href = refurl;
				}else{
					return false;
				}
			})
		});
	})
</script>
<script type="text/javascript">
$(function(){
	$("#searchsubmit").click(function(){
		
		var key = $("input[name='searkey']").val();
		$.post("{:U('Index/getjma')}", {key:key,random:Math.random()}, function(data){
		   if(data!=0){
			   $(".jiumalist").html(data);
		   }else{
			   $(".jiumalist").html("<span>没有数据!</span>");
		   }
		})

	})	
	
	$(".tbu").each(function(index, element) {
        var t = $(this);
		t.find("span").click(function(){
			var vlue = $(this).attr("v");
			$(".jiumabg").fadeIn();
			$(".jiumabg .jiuma").show();
			$("input[name='ycid']").val(vlue);

			$.get("{:U('Index/getjma')}", function(data){
			   if(data!=0){
				   $(".jiumalist").html(data);
			   }else{
				   $(".jiumalist").html("<span>没有数据返回!</span>");
			   }
			})
		})
    });
	$(".jiumaclose").click(function(){
		$(".jiumalist").html(null);
		$(".jiumabg .jiuma").hide();
		$(".jiumabg").fadeOut();
	})
	
})
</script>
</body>
</html>
